//
// 作者：AKA_GGbond
// 时间：2025/7/16
// 邮箱：evain_wl@163.com
//

#ifndef ESMU_W_LOGINBUTTON_H
#define ESMU_W_LOGINBUTTON_H

#include <QPushButton>

class QPropertyAnimation;

class W_LoginButton : public QPushButton
{
    Q_OBJECT
    Q_PROPERTY(QColor bgColor READ bgColor WRITE setbgColor FINAL)
    Q_PROPERTY(int color_opacity READ color_opacity WRITE setColor_opacity FINAL)
    Q_PROPERTY(QString center_text READ center_text WRITE setCenter_text FINAL)

public:
    explicit W_LoginButton(QWidget *parent = nullptr);
    ~W_LoginButton();

    enum AnimationState {
        Execute,
        Restore
    };

public:
    QColor bgColor() const;
    void setbgColor(QColor bgColor);

    int color_opacity() const;
    void setColor_opacity(int newColor_opacity);

    QString center_text() const;
    void setCenter_text(const QString &newCenter_text);

protected:
    void paintEvent(QPaintEvent *event);
    bool event(QEvent* e);
    void mousePressEvent(QMouseEvent *event);
    void mouseReleaseEvent(QMouseEvent *event);

private:
    void drawText();
    void startAnimation();

signals:
    void execute_animation_signal(W_LoginButton::AnimationState state);

private:
    QPropertyAnimation *m_animation{nullptr};
    QColor m_bgColor{123, 150, 228, 255};
    int m_color_opacity = 255;
    QString m_center_text;
};


#endif //ESMU_W_LOGINBUTTON_H
